$(document).ready(function () {
    setCamp();//集训营
    setClass();//课程体系
    setTeachers();//师资团队
    setCarousel();//师资轮播
    setTop();//顶部广告轮播
    setBtn();//6大金钻班型


    setTimeout(function () {
        $(".active-prompt").show();
    }, 500);


    function setBtn() {
        var tdStyle = $(".class_list tbody tr td");
        tdStyle.hover(function () {
            $(this).find('.know_more_two').removeClass('hideDom')
        });
        tdStyle.mouseleave(function () {
            $(this).find('.know_more_two').addClass('hideDom')
        })
    }
    
    function setTop() {
        var visual = $(".main_visual");
        var mainImg = $(".main_image");
        visual.hover(function(){
            $("#btn_prev,#btn_next").fadeIn()
        },function(){
            $("#btn_prev,#btn_next").fadeOut()
        });
        $dragBln = false;
        mainImg.touchSlider({
            flexible : true,
            speed : 200,
            btn_prev : $("#btn_prev"),
            btn_next : $("#btn_next"),
            paging : $(".flicking_con a"),
            counter : function (e){
                $(".flicking_con a").removeClass("on").eq(e.current-1).addClass("on");
            }
        });
        mainImg.bind("mousedown", function() {$dragBln = false;});
        mainImg.bind("dragstart", function() {$dragBln = true;});
        $(".main_image a").click(function(){
            if($dragBln) {return false;}
        });
        timer = setInterval(function(){
            $("#btn_next").click();}, 3000);
        visual.hover(function(){
            clearInterval(timer);
        },function(){
            timer = setInterval(function(){$("#btn_next").click();},3000);
        });
        mainImg.bind("touchstart",function(){
            clearInterval(timer);
        }).bind("touchend", function(){
            timer = setInterval(function(){
                $("#btn_next").click();
            }, 3000);
        });
    }

    function setCarousel() {
        $(".js-silder").silder({
            auto: true,//自动播放，传入任何可以转化为true的值都会自动轮播
            speed: 20,//轮播图运动速度
            sideCtrl: true,//是否需要侧边控制按钮
            bottomCtrl: true,//是否需要底部控制按钮
            defaultView: 0,//默认显示的索引
            interval: 4000,//自动轮播的时间，以毫秒为单位，默认3000毫秒
            activeClass: "active",//小的控制按钮激活的样式，不包括作用两边，默认active
        });
    }



    function setClass() {
        var select = $(".know_more_one");
        var selectTwo = $(".know_more_two");
        var selectThree = $(".learn_more");
        selectThree.hover(function () {
            $(this).addClass('setBackImg')
            $(this).siblings('.select').hide();
            $(this).siblings('.selected').show();
        });
        selectThree.mouseleave(function () {
            $(this).removeClass('setBackImg')
            $(this).siblings('.select').show();
            $(this).siblings('.selected').hide();
        });
        selectTwo.hover(function () {
            $(this).addClass('setBackImg')
            $(this).siblings('.select').hide();
            $(this).siblings('.selected').show();
        });
        selectTwo.mouseleave(function () {
            $(this).removeClass('setBackImg')
            $(this).siblings('.select').show();
            $(this).siblings('.selected').hide();
        });
        select.hover(function () {
            $(this).addClass('setBackImg');
            $(this).siblings('ul').find('.select').hide();
            $(this).siblings('ul').find('.selected').show();
        });
        select.mouseleave(function () {
            $(this).removeClass('setBackImg');
            $(this).siblings('ul').find('.select').show();
            $(this).siblings('ul').find('.selected').hide();
        });
    }



    function setCamp() {
        var selectOne = $(".learn_more");
        selectOne.hover(function () {
            $(this).siblings('.camp_box').children('.camp_unselected').hide();
            $(this).siblings('.camp_box').children('.camp_box_font').hide();
            $(this).siblings('.camp_box').addClass('set_background');
            $(this).siblings('.camp_box').children('.camp_selected').show();
            $(this).siblings('.camp_box').children('.camp_box_fontTwo').show();
        });
        selectOne.mouseleave(function () {
            $(this).siblings('.camp_box').removeClass('set_background');
            $(this).siblings('.camp_box').children('.camp_selected').hide();
            $(this).siblings('.camp_box').children('.camp_box_fontTwo').hide();
            $(this).siblings('.camp_box').children('.camp_unselected').show();
            $(this).siblings('.camp_box').children('.camp_box_font').show();
        });
    }
    function setTeachers() {
        var selectTwo = $(".learn_moreThree");
        selectTwo.hover(function () {
            // $(this).siblings('.teacher_info').attr('color','white')

            $(this).parent().addClass('set_teacher_background');
            $(this).siblings('.teacher_info').children('.skillInfo').addClass('set_teacher_levelBack');
            // $(this).siblings('.teacher_info').children('.setChange').addClass('setColor');
            $(this).siblings('.teacher_info').children().addClass('setColor')

        });
        selectTwo.mouseleave(function () {
            $(this).parent().removeClass('set_teacher_background');
            $(this).siblings('.teacher_info').children('.skillInfo').removeClass('set_teacher_levelBack');
            $(this).siblings('.teacher_info').children().removeClass('setColor')
            // $(this).siblings('.teacher_info').children('.name').addClass('setColor')
        });
    }

});

// 关闭弹框
function closePrompt() {
    $('.active-prompt').css('display','none');
}


var changeTitle= function(changeId,id1,id2,id3){
    var content = $(".content_area");
    $("#title"+changeId).css("background-color","#2974FF").css("color","white");
    $("#title"+id1).css("background-color","rgb(245, 245, 245)").css("color","#A3A3A3");
    $("#title"+id2).css("background-color","rgb(245, 245, 245)").css("color","#A3A3A3");
    $("#title"+id3).css("background-color","rgb(245, 245, 245)").css("color","#A3A3A3");
    if(changeId ===1){
        // $(".greater_area").animate({
        //     "opacity":"0"
        // },500).hide(1000);
        $(".greater_area").animate({"opacity":"1"},500).removeClass('hideDom')
        $(".education_area").animate({"opacity":"0"},500).addClass('hideDom');
        $(".exercise_area").animate({"opacity":"0"},500).addClass('hideDom');
        $(".staff_area").animate({"opacity":"0"},500).addClass('hideDom');
    }
    if(changeId ===2){
        $(".greater_area").animate({"opacity":"0"},500).addClass('hideDom')
        $(".education_area").animate({"opacity":"1"},500).removeClass('hideDom');
        $(".exercise_area").animate({"opacity":"0"},500).addClass('hideDom');
        $(".staff_area").animate({"opacity":"0"},500).addClass('hideDom');
    }
    if(changeId ===3){
        $(".greater_area").animate({"opacity":"0"},500).addClass('hideDom')
        $(".education_area").animate({"opacity":"0"},500).addClass('hideDom');
        $(".exercise_area").animate({"opacity":"1"},500).removeClass('hideDom');
        $(".staff_area").animate({"opacity":"0"},500).addClass('hideDom');
    }
    if(changeId ===4){
        $(".greater_area").animate({"opacity":"0"},500).addClass('hideDom')
        $(".education_area").animate({"opacity":"0"},500).addClass('hideDom');
        $(".exercise_area").animate({"opacity":"0"},500).addClass('hideDom');
        $(".staff_area").animate({"opacity":"1"},500).removeClass('hideDom');
    }
};